<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <link rel="icon" href="/assets/bootstrap/favicon.ico" type="image/ico">
  <link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
  <div class="row">
    <div class="card">
      <div class="card-body">
        <form class="form-horizontal" id="codeForm" onsubmit="return false;">
          <div class="form-group">
            <label class="col-md-3 control-label">文件夹名称</label>
            <div class="col-md-7">
              <input class="form-control" autocomplete="off" id="name" name="name">
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-9 col-md-offset-3">
              <button class="btn btn-primary" type="button" onclick="sub()">提交</button>
            </div>
          </div>
        </form>

      </div>
    </div>
  </div>
</div>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/main.min.js"></script>
<script src="/assets/bootstrap/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/lightyear.js"></script>
<script>
  function sub() {
    lightyear.loading('show');  // 显示
    var name = $("#name").val();
    if (name == "" )
    {
      lightyear.loading('hide');  // 隐藏
      lightyear.notify('文件夹名称不能为空！', 'warning', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
      return false;
    }
    $.ajax({
      type: "POST",//方法类型
      dataType: "json",//预期服务器返回的数据类型
      url: "/api/dir/set" ,//url
      data: $('#codeForm').serialize(),
      success: function (result) {
        lightyear.loading('hide');  // 隐藏
        if (result.code == 200) {
          lightyear.notify('生成成功~', 'success', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
          setTimeout(function () {
            parent.location.reload();
          },1000)
        }else{
          lightyear.notify('异常！'+result.msg, 'warning', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
        }
      },
      error : function(result) {
        lightyear.loading('hide');  // 隐藏
        lightyear.notify('异常！' + result.msg, 'warning', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
      }
    });
  }
</script>
</body>
</html>